import request from '../base.ts';

const url = '/login_user';

export const login = function (data: IObj) {
  return request.post(`${url}/login`, data);
}

export const getList = function (params: IObj) {
  return request(`${url}/admin/viewAllUser`, {params})
}

export const getAll = function () {
  return request.get(`${url}/admin/getAll`);
}

export const addUSer = function (data: IObj) {
  return request.post(`${url}/admin/addUser`, data);
}

export const editUser = function (params: IObj) {
  return request({
    url: `${url}/admin/editUser`,
    method: 'post',
    params
  })
}

export const resetPwd = function (userId: number) {
  return request({
    url: `${url}/admin/refreshPassword`,
    method: 'post',
    params: {
      userId
    }
  })
}

export const deleteUser = function (_id: number) {
  return request.delete(`${url}/admin/deleteUser`, {
    params: {
      _id
    }
  })
}

export const deleteUserList = (data: number[]) => {
  console.log(data);
  return request.delete(`${url}/admin/deleteUserList`, {
    data
  });
}

export const getRole = () => {
  return request.get(`${url}/getRole`);
}

// 修改密码
export const changePassword = (data: IObj) => {
  return request({
    url: `${url}/changePassword`,
    method: 'post',
    data
  })
} 